package com.aso.common.sp;

import android.content.Context;
import android.text.TextUtils;

import com.aso.common.utils.Utils;

import java.util.Set;

/**
 * @Description ：SharedPreferences 工具类
 * @Author itsdf07
 * @Time 2017/11/30
 */

public class SPHelper {
    public class SPKeyGlobal {
        /**
         * Ble设备Mac地址
         */
        public static final String KEY_BLE_MAC = "ble_mac";

        public static final String KEY_POWER_WAKELOCK = "power_wakelock";
    }

    private static ISharedPreference getSP() {
        return getSP(null);
    }

    private static ISharedPreference getSP(String fileName) {
        return SharedPreferenceImpl.getSP(Utils.getApplication().getApplicationContext(), fileName);
    }

    public static void put(String key, Object value) {
        getSP().put(key, value);
    }

    public static String getString(String key) {
        return getSP().getString(key);
    }

    public static String getString(String key, String defaultString) {
        String value = getSP().getString(key);
        return TextUtils.isEmpty(value) ? defaultString : value;
    }

    public static float getFloat(String key) {
        return getSP().getFloat(key);
    }

    public static float getFloat(String key, float defaultFloat) {
        float value = getSP().getFloat(key);
        return value < 0 ? defaultFloat : value;
    }

    public static int getInteger(String key) {
        return getSP().getInteger(key);
    }

    public static int getInteger(String key, int defalutInt) {
        int value = getSP().getInteger(key);
        return value < 0 ? defalutInt : value;
    }

    public static long getLong(String key) {
        return getSP().getLong(key);
    }

    public static long getLong(String key, long defaultLong) {
        long value = getSP().getLong(key);
        return value < 0 ? defaultLong : value;
    }

    /**
     * 待封装
     *
     * @param key
     * @param defaultBoolean
     * @return
     */
    private boolean getBoolean(String key, boolean defaultBoolean) {
        return false;
    }
}
